package com.example.demo2.service;


import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class Task {
    @Async
    public void doTaskOne() throws InterruptedException {
        println("taskOne start" + System.currentTimeMillis());
        TimeUnit.SECONDS.sleep(1);
        println("taskOne end" + System.currentTimeMillis());
    }

    @Async
    public void doTaskTwo() throws InterruptedException {
        println("taskTwo start" + System.currentTimeMillis());
        TimeUnit.SECONDS.sleep(1);
        println("taskTwo end" + System.currentTimeMillis());
    }

    private void println(Object object) {
        System.out.println(object);
    }

}

